package PTA.javaA;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import static PTA.ch06.fn01.convertStringToList;
import static PTA.ch06.fn01.remove;

public class fn05 {

    /*covnertStringToList函数代码*/
    public static List<String> convertStringToList(String line){
        List<String> list =  new ArrayList<String>();
        String s[] = line.split("\\s+");
        for(int i=0;i< s.length;i++){
            list.add(s[i]);
        }
        return list;
    }
    /*remove函数代码*/
    public static void remove(List<String> list, String str){
      int count=0;
        for(int i=0;i<list.size();){
            if(list.get(i).equals(str)){
                list.remove(i);
                i=0;
            }else{
                i++;
            }

        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            List<String> list = convertStringToList(sc.nextLine());
            System.out.println(list);
            String word = sc.nextLine();
            remove(list,word);
            System.out.println(list);
        }
        sc.close();
    }

}
